<template>
  <div class="detail">
    <van-nav-bar
      left-text="返回"
      @click-left="$router.back()"
      fixed
      title="我的通行码"
    />
    <div class="title-padding"></div>
    <img v-if="isPass" class="passImg" src="../assets/img/truePass.png" />
    <img v-else class="passImg" src="../assets/img/falsePass.png" />
    <van-cell title="审核状态" :value="sfsh"></van-cell>
    <van-cell title="离开时间" :value="likaishijian"></van-cell>

    <van-button class="backBtn" type="danger" round @click="returnBack()"
      >返回</van-button
    >
  </div>
</template>

<script>
/* eslint-disable */
export default {
  name: "record-detail",
  data() {
    return {
      show: false,
      rateData: {
        message: "",
        score: 0,
      },
      sfsh: "",
      isPass: false,
      laifangshijian: "",
    };
  },
  methods: {
    returnBack() {
      this.$router.back();
    },
    showModal() {
      this.show = true;
    },
    onBeforeClose(action, done) {
      // 在这里可以进行一些关闭前的处理
      if (action === "confirm") {
        // 用户点击了确认按钮
        // 这里可以做一些提交数据的操作
        console.log("提交评价");
        console.log("rateData", { ...this.rateData });
        this.rateData = {};
      } else if (action === "cancel") {
        // 用户点击了取消按钮或者点击了遮罩层关闭对话框
        console.log("取消评价");
      }
      done();
      // 如果要阻止对话框关闭，可以返回 false
      // return false;
    },
  },
  created() {
    this.sfsh = this.$route.query.sfsh;
    this.likaishijian = this.$route.query.likaishijian;
    let currentTime = new Date();
    let likaishijian = new Date(this.likaishijian);
    // 比较时间
    if (currentTime < likaishijian && this.sfsh === "通过") {
      this.isPass = true;
    } else {
      this.isPass = false;
    }
  },
  watch: {
    $route(to, from) {
      if (to.path == "/passcode") {
        this.sfsh = to.query.sfsh;
        this.likaishijian = to.query.likaishijian;
        let currentTime = new Date();
        let likaishijian = new Date(this.likaishijian);
        // 比较时间
        if (currentTime < likaishijian && this.sfsh === "通过") {
          this.isPass = true;
        } else {
          this.isPass = false;
        }
      }
    },
  },
};
</script>

<style scoped>
.detail {
  padding: 20px;
}
.title-padding {
  padding-top: 5vh;
}

.backBtn {
  margin-top: 1vh;
  margin-left: 0.5vh;
  /* margin-left: 35vw; */
  width: 90vw;
}

.passImg {
  width: 90vw;
  height: 80vw;
}
</style>
